import math
import turtle

spiral = turtle.Turtle()

r = 300
R = 410
delta = 100

spiral.penup()
spiral.goto(0, R - delta)
spiral.pendown()

for i in range(360 * 50):
    # 小圆圆心位置
    rad = i * math.pi / 180
    x = (R - r - 50) * math.sin(rad)  # -50表示椭圆的长边
    y = (R - r) * math.cos(rad)

    # 小圆顶点位置
    rad2 = rad * R / r
    x -= (r - delta) * math.sin(rad2 - rad)
    y += (r - delta) * math.cos(rad2 - rad)

    spiral.goto(x, y)

spiral.done()
